package com.yy.finvideoplayer.media

import android.content.Context
import android.view.Surface
import android.view.SurfaceHolder

/**
 * @Description: IMediaControl
 * @Author: yiw89
 * @CreateDate: 2025/9/1 13:43
 * @Version: 1.0
 */
interface IMediaControl {
    fun doPrepare(
        context: Context,
        url: String,
        headers: Map<String, String?>?,
        vararg objects: Any?
    ): Boolean //准备播放

    fun setSurface(surface: Surface) //api14以上用这个 可以无缝全屏切换

    fun setDisplay(surfaceHolder: SurfaceHolder?) //api14一下用这个 全屏切换会顿一下

    fun doPlay() //播放

    fun doPause() //暂停

    fun seekTo(du: Int) //调整播放进度

    fun getCurrentPosition(): Int //当前播放进度

    fun getDuration(): Int //视频长度

    fun getVideoHeight(): Int

    fun getVideowidth(): Int

    fun isPlaying(): Boolean

    fun setVolume(leftVol: Float, rightVol: Float): Boolean

    fun setSpeed(rate: Float): Boolean //设置播放倍速,false不支持

    fun setLooping(isLooping: Boolean)


    fun release() //销毁

    companion object {
        const val MEDIA_INFO_UNKNOWN: Int = 1
        const val MEDIA_INFO_STARTED_AS_NEXT: Int = 2
        const val MEDIA_INFO_VIDEO_RENDERING_START: Int = 3
        const val MEDIA_INFO_VIDEO_TRACK_LAGGING: Int = 700
        const val MEDIA_INFO_BUFFERING_START: Int = 701
        const val MEDIA_INFO_BUFFERING_END: Int = 702
        const val MEDIA_INFO_NETWORK_BANDWIDTH: Int = 703
        const val MEDIA_INFO_BAD_INTERLEAVING: Int = 800
        const val MEDIA_INFO_NOT_SEEKABLE: Int = 801
        const val MEDIA_INFO_METADATA_UPDATE: Int = 802
        const val MEDIA_INFO_TIMED_TEXT_ERROR: Int = 900
        const val MEDIA_INFO_UNSUPPORTED_SUBTITLE: Int = 901
        const val MEDIA_INFO_SUBTITLE_TIMED_OUT: Int = 902
        const val MEDIA_INFO_VIDEO_ROTATION_CHANGED: Int = 10001
        const val MEDIA_INFO_AUDIO_RENDERING_START: Int = 10002
        const val MEDIA_ERROR_UNKNOWN: Int = 1
        const val MEDIA_ERROR_SERVER_DIED: Int = 100
        const val MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK: Int = 200
        const val MEDIA_ERROR_IO: Int = -1004
        const val MEDIA_ERROR_MALFORMED: Int = -1007
        const val MEDIA_ERROR_UNSUPPORTED: Int = -1010
        const val MEDIA_ERROR_TIMED_OUT: Int = -110
    }
}